import Taro, {Component} from '@tarojs/taro'
import {View, Text, Image} from '@tarojs/components'
import {connect} from '@tarojs/redux'

class Panel extends Component {
  toDetail (id) {
    Taro.navigateTo({url: '/pages/detail/index?topicid=' + id})
  }
  render () {
    let {listData, title} = this.props
    return (
      <View className='panel-wrap'>
        <View className='panel-til'>{title}</View>
        <View className='panel-body'>
          {
            listData.map((item)=> {
              return (
                <View className='panel-body-list' key={item.id} onClick={this.toDetail.bind(this, item.id)}>
                  <Image className='panel-body-img' src={item.author ? item.author.avatar_url : null  }/>
                  <Text className='panel-body-text'>{item.title}</Text>
                </View>
              )
            })
          }
        </View>
      </View>
    )
  }
}

export default Panel